home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / gpt32src.zip / IRIS4D.TRM < prev    next >
Text File  |  1992-03-25  |  6KB  |  237 lines

  1. /*
  2.  * $Id: iris4d.trm,v 3.26 92/03/24 22:35:35 woo Exp Locker: woo $
  3.  */
  4.  
  5. /* GNUPLOT - iris4d.trm */
  6. /*
  7.  * Copyright (C) 1990, 1991, 1992   
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted, 
  11.  * provided that the above copyright notice appear in all copies and 
  12.  * that both that copyright notice and this permission notice appear 
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed 
  17.  * as patches to released version.
  18.  *  
  19.  * This software  is provided "as is" without express or implied warranty.
  20.  * 
  21.  * This file is included by ../term.c.
  22.  *
  23.  * This terminal driver supports:
  24.  *   IRIS terminals
  25.  *
  26.  * AUTHORS
  27.  *   John H. Merritt 
  28.  *           (Applied Research Corporation) 7/1/89
  29.  *           INTERNET: merritt@iris613.gsfc.nasa.gov
  30.  * 
  31.  * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
  32.  * 
  33.  */
  34.  
  35. #include <gl.h>
  36.  
  37. #define IRIS4DRC    ".gnuplot_iris4d"
  38.  
  39. #define IRIS4D_XMAX 1024
  40. #define IRIS4D_YMAX 1024
  41.  
  42. #define IRIS4D_XLAST (IRIS4D_XMAX - 1)
  43. #define IRIS4D_YLAST (IRIS4D_YMAX - 1)
  44.  
  45. #define IRIS4D_VCHAR (IRIS4D_YMAX/30)
  46. #define IRIS4D_HCHAR (IRIS4D_XMAX/72)
  47. #define IRIS4D_VTIC (IRIS4D_YMAX/80)
  48. #define IRIS4D_HTIC (IRIS4D_XMAX/80)
  49.  
  50. static short colors24bits[][3] =
  51. {
  52.     { 85,  85,  85  },  /* 0. BACK GROUND ( DARKGRAY ) */
  53.     { 0,   0,   0   },  /* 1. BLACK */
  54.     { 170, 0,   170 },  /* 2. MAGENTA */
  55.     { 85,  255, 255 },  /* 3. LIGHTCYAN */
  56.     { 170, 0,   0   },  /* 4. RED */
  57.     { 0,   170, 0   },  /* 5. GREEN */
  58.     { 255, 85,  255 },  /* 6. LIGHTMAGENTA */
  59.     { 255, 255, 85  },  /* 7. YELLOW */
  60.     { 255, 85,  85  },  /* 8. LIGHTRED */
  61.     { 85,  255, 85  },  /* 9. LIGHTGREEN */
  62.     { 0,   170, 170 },  /* 10. CYAN */
  63.     { 170, 170, 0   },  /* 11. BROWN */
  64. };
  65. #define COLOR24_SIZE (sizeof(colors24bits) / (sizeof(short) * 3))
  66.  
  67. static iris24bits = FALSE;
  68.  
  69. #define IRIS4D_BACKGROUND    0
  70. #define IRIS4D_BLACK        1
  71. #define IRIS4D_MAGENTA        2
  72. #define IRIS4D_LIGHTCYAN    3
  73. #define IRIS4D_RED        4
  74. #define IRIS4D_GREEN        5
  75. #define IRIS4D_LIGHTMAGENTA    6
  76. #define IRIS4D_YELLOW        7
  77. #define IRIS4D_LIGHTRED        8
  78. #define IRIS4D_LIGHTGREEN    9
  79. #define IRIS4D_CYAN        10
  80. #define IRIS4D_BROWN        11
  81.  
  82. IRIS4D_options()
  83. {
  84.   int i = 0;
  85.   struct value a;
  86.   extern struct value *const_express();
  87.   extern double real();
  88.  
  89.   if (!END_OF_COMMAND) {
  90.     i = (int) real(const_express(&a));
  91.   }
  92.  
  93.   iris24bits = (i == 24);
  94.  
  95.   sprintf(term_options, "%s",iris24bits ? "24" : "8");
  96. }
  97.  
  98. IRIS4D_init()
  99. {
  100.   int i;
  101.   char homedirfile[80], line[80];
  102.   FILE *f;
  103.  
  104.   foreground();
  105.   winopen("Gnuplot");
  106.   if (iris24bits)
  107.   {
  108.     RGBmode();
  109.     gconfig();
  110.   }
  111.  
  112.   strcat(strcat(strcpy(homedirfile,getenv("HOME")),"/"),IRIS4DRC);
  113.   if ((f = fopen(IRIS4DRC, "r")) != NULL ||
  114.       (f = fopen(homedirfile, "r")) != NULL) {
  115.     int c1, c2, c3;
  116.     for (i = 0; i < COLOR24_SIZE; i++) {
  117.       if (fgets(line, 79, f) == NULL ||
  118.       sscanf(line, "%d %d %d", &c1, &c2, &c3) != 3)
  119.     int_error("Iris4d color file terminated prematurely or wrong format.\n", NO_CARET);
  120.       colors24bits[i][0] = c1;
  121.       colors24bits[i][1] = c2;
  122.       colors24bits[i][2] = c3;
  123.     }
  124.       
  125.     fclose(f);
  126.   }
  127.   deflinestyle(1, 0x3FFF); /* long dash */
  128.   deflinestyle(2, 0x5555); /* dotted */
  129.   deflinestyle(3, 0x3333); /* short dash */
  130.   deflinestyle(4, 0xB5AD); /* dotdashed */
  131.   deflinestyle(5, 0x0F0F); /* dashed */
  132.   deflinestyle(6, 0xBBBB); /* dotdashed */
  133.   deflinestyle(7, 0x3F3F); /* mid-long dash */
  134.   deflinestyle(8, 0x7777); /* mid-long dash */
  135.  
  136.   return;
  137. }
  138.  
  139. IRIS4D_graphics()
  140. {
  141.   reshapeviewport();
  142.   ortho2((Coord)0, (Coord)IRIS4D_XMAX, (Coord)0, (Coord)IRIS4D_YMAX);
  143.   if (iris24bits)
  144.     RGBcolor(colors24bits[IRIS4D_BACKGROUND][0],
  145.          colors24bits[IRIS4D_BACKGROUND][1],
  146.          colors24bits[IRIS4D_BACKGROUND][2]);
  147.   else
  148.     color(WHITE);
  149.  
  150.   clear();
  151.   
  152.   return;
  153. }
  154.  
  155. IRIS4D_text()
  156. {
  157.   return; /* enter text from another window!!! */
  158. }
  159.  
  160. IRIS4D_linetype(linetype)
  161. int linetype;
  162. {
  163.   static int pen_color_24[11] =
  164.     {
  165.       IRIS4D_BLACK,        /* reserved for border and numbers */
  166.       IRIS4D_MAGENTA,        /* reserved for axis traces */
  167.       IRIS4D_LIGHTCYAN,
  168.       IRIS4D_RED,
  169.       IRIS4D_GREEN,
  170.       IRIS4D_LIGHTMAGENTA,
  171.       IRIS4D_YELLOW,
  172.       IRIS4D_LIGHTRED,
  173.       IRIS4D_LIGHTGREEN,
  174.       IRIS4D_CYAN,
  175.       IRIS4D_BROWN,
  176.     };
  177.   static int pen_color[8] = {0 ,1, 4, 5, 6, 1, 2, 4};
  178.  
  179.   if (iris24bits)
  180.   {
  181.     int pencolor = pen_color_24[linetype < 0 ? linetype + 2 : linetype % 9 + 2];
  182.  
  183.     RGBcolor(colors24bits[pencolor][0],
  184.          colors24bits[pencolor][1],
  185.          colors24bits[pencolor][2]);
  186.     /* Make all lines solid (linestyle 0) upto to the ninth. If more than
  187.      * 9 colors are needed, start to use the different line styles (1 to 8).
  188.      */
  189.     setlinestyle(linetype < 9 ? 0 : (linetype + 2) % 8 + 1);
  190.   }
  191.   else
  192.   {
  193.     linetype = linetype % 8;
  194.     color((Colorindex) pen_color[linetype]);
  195.     setlinestyle(linetype);
  196.   }
  197.   return;
  198. }
  199.  
  200. IRIS4D_move(x, y)
  201. unsigned int x, y;
  202. {
  203.   move2i(x, y);
  204.   return;
  205. }
  206.  
  207. IRIS4D_cmove(x, y)
  208. unsigned int x, y;
  209. {
  210.   cmov2i(x, y);
  211.   return;
  212. }
  213.  
  214. IRIS4D_vector(x, y)
  215. unsigned x, y;
  216. {
  217.   draw2i(x, y);
  218.   return;
  219. }
  220.  
  221.  
  222. IRIS4D_put_text(x,y,str)
  223. int x, y;
  224. char *str;
  225. {
  226.   IRIS4D_cmove(x,y - IRIS4D_VCHAR/2);
  227.   charstr(str);
  228.   return;
  229. }
  230.  
  231.  
  232. IRIS4D_reset()
  233. {
  234.   return;
  235. }
  236.  
  237.